
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Администратор
 */
public class CopyFile {
    
    /**Copies file from source to dest
     * 
     * @param source - source file
     * @param dest - dest file
     * @author Cloud
     * @return True only if file copied without Exceptions
     */
    public Boolean copyFile(File source, File dest) {
        FileInputStream is = null;
        FileOutputStream os = null;
        try {
            is = new FileInputStream(source);
            os = new FileOutputStream(dest);
            int nLength;
            byte[] buf = new byte[8000];
            while (true) {
                nLength = is.read(buf);
                if (nLength < 0) {
                    break;
                }
                os.write(buf, 0, nLength);
            }
            return true;
        } catch (IOException ex) {
             
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (Exception ex) {
                }
            }
            if (os != null) {
                try {
                    os.close();
                } catch (Exception ex) {
                }
            }
        }
        return false;
    }
    
        public static void main(String[] args) throws IOException {
        
       File file_in = new File("soft/DBF2FTxt.exe");  
       File file_out = new File("F:/NetBeansProjects/DbfSybaseIQ/DBF2FTxt.exe"); 
       
            
        CopyFile runCommand = new CopyFile();
        
        runCommand.copyFile(file_in,file_out );
    }
    
}
